package nathizm;

import java.io.IOException;
import java.net.URL;

import com.google.gdata.client.Query;
import com.google.gdata.client.blogger.BloggerService;
import com.google.gdata.data.DateTime;
import com.google.gdata.data.Entry;
import com.google.gdata.data.Feed;
import com.google.gdata.util.ServiceException;

public class Download extends Blogger {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		
		try {

			BloggerService myService = getService();
			URL feedUrl = new URL(FEED_URI + POSTS_FEED_URI_SUFFIX);
			Query myQuery = new Query(feedUrl);
			myQuery.setPublishedMin(DateTime.parseDate(args[0]));
			myQuery.setPublishedMax(DateTime.parseDate(args[1]));
			myQuery.setMaxResults(200);
			Feed resultFeed = myService.query(myQuery, Feed.class);

			// Print the results
			for (int i = 0; i < resultFeed.getEntries().size(); i++) {
				Entry entry = resultFeed.getEntries().get(i);
				outputFile(entry);
				// System.out.println("\t" +
				// entry.getUpdated().toStringRfc822());
			}
			// System.out.println();

		} catch (ServiceException se) {
			se.printStackTrace();
		} catch (IOException ioe) {
			ioe.printStackTrace();
		}

	}

}
